package com.example.demo.Dao;

import com.example.demo.Pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Repository
public class DepartmentDao {
    //    模拟数据库数据
    private static List<Department> list;
    static {
        list = new ArrayList<>();
        list.add(new Department(101,"部门1"));
        list.add(new Department(102,"部门2"));
        list.add(new Department(103,"部门3"));
        list.add(new Department(104,"部门4"));
        list.add(new Department(105,"部门5 "));
    }
//    获得所有哪里部门信息
    public Collection<Department> getDepartments(){
        return list;
    }
    public Department getDepartment(Integer id){
        int flag = Integer.parseInt(null);
        for (int i = 0; i < list.size(); i++) {
            if (id == list.get(i).getId()){
                list.get(i);
                flag = i;
                break;
            }
        }
        return list.get(flag);
    }
}
